import cv2
import numpy as np

img = cv2.imread('IMG_1745.JPG')
new_size = (1200, 800)
img = cv2.resize(img, new_size)

# 转换到LAB颜色空间
lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
lower_red = np.array([0, 100, 150])    # H:0-10°, 高饱和度
upper_red = np.array([15, 255, 255])   # 覆盖橙色偏移
mask = cv2.inRange(lab, lower_red, upper_red)

# 增强红色通道对比度（补偿蓝光干扰）
r_channel = img[:,:,2]
clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8,8))
enhanced_r = clahe.apply(r_channel)
enhanced_l = cv2.bitwise_and(enhanced_r, enhanced_r, mask=mask)

cv2.imshow("binary", enhanced_l)
cv2.waitKey(0)
